// 代码块 importM
import 'package:flutter/material.dart';

import './myFont.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: Scaffold(
        appBar: AppBar(
          title: const Text("Flutter app"),
        ),
        body: const MyHomePage(),
      ),
    );
  }
}

class MyHomePage extends StatelessWidget {
  const MyHomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return SizedBox(
        height: 120,
        child: ListView(
            padding: const EdgeInsets.all(10),
            scrollDirection: Axis.horizontal, // 水平列表 高度自适应，宽度需定义。需要设置高度须在外层容器设置
            // scrollDirection: Axis.vertical, // 垂直列表（默认）宽度自适应
            children: <Widget>[
              Container(
                width: 120,
                decoration: const BoxDecoration(color: Colors.red),
                child: Column(
                  children: [
                    SizedBox(
                      height: 80,
                      child: Image.network(
                        "https://tse3-mm.cn.bing.net/th/id/OIP-C.FYx55PIoNajL-lEV5UhFlAHaNK?rs=1&pid=ImgDetMain",
                        fit: BoxFit.cover,
                      ),
                    ),
                    const Text('文字')
                  ],
                ),
              ),
              Container(
                width: 120,
                decoration: const BoxDecoration(color: Colors.pink),
                child: Column(
                  children: [
                    SizedBox(
                      height: 80,
                      child: Image.network(
                        "https://tse3-mm.cn.bing.net/th/id/OIP-C.FYx55PIoNajL-lEV5UhFlAHaNK?rs=1&pid=ImgDetMain",
                        fit: BoxFit.cover,
                      ),
                    ),
                    const Text('文字')
                  ],
                ),
              ),
              Container(
                width: 120,
                decoration: const BoxDecoration(color: Colors.yellow),
                child: Column(
                  children: [
                    SizedBox(
                      height: 80,
                      child: Image.network(
                        "https://tse3-mm.cn.bing.net/th/id/OIP-C.FYx55PIoNajL-lEV5UhFlAHaNK?rs=1&pid=ImgDetMain",
                        fit: BoxFit.cover,
                      ),
                    ),
                    const Text('文字')
                  ],
                ),
              ),
              Container(
                width: 120,
                decoration: const BoxDecoration(color: Colors.blue),
                child: Column(
                  children: [
                    SizedBox(
                      height: 80,
                      child: Image.network(
                        "https://tse3-mm.cn.bing.net/th/id/OIP-C.FYx55PIoNajL-lEV5UhFlAHaNK?rs=1&pid=ImgDetMain",
                        fit: BoxFit.cover,
                      ),
                    ),
                    const Text('文字')
                  ],
                ),
              ),
            ]));
  }
}
